<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<div class="span8 offset2">
    <form class="form-horizontal well" method="POST" action="MainServlet?action=bus.save" onsubmit="return checkBus();">
        <fieldset>
            <legend>New bus</legend>
            <div class="hidden">
                <input type="hidden" name="id" value="0">
            </div>         
                    
            <div id="stateNumberControlGroup" class="control-group">
                <label class="control-label" for="stateNumber">State number:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="stateNumber" name="stateNumber" value="">
                    <span id="stateNumberHelpInline" class="help-inline"></span>
                </div>
            </div>
                    
            <div id="modelNameControlGroup" class="control-group">
                <label class="control-label" for="modelName">Model name:</label>
                <div class="controls">
                    <select class="myinput" id="modelName" name="modelName">
                        <option value="0" disabled="true" selected="true">choose model</option>
                            <c:forEach var="bus" items="${busList}">
                                <option value="<c:out value="${bus.getBusModel().getId()}" />"><c:out value="${bus.getBusModel().getModelName()}" /></option>
                            </c:forEach>
                    </select>
                    <span id="modelNameHelpInline" class="help-inline"></span>
                </div>
            </div>

            <div id="startYearOfExploitationControlGroup" class="control-group">
                <label class="control-label" for="startYearOfExploitation">Start year of exploitation:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="startYearOfExploitation" name="startYearOfExploitation" value="">
                    <span id="startYearOfExploitationHelpInline" class="help-inline"></span>
                </div>
            </div>
            
            <div id="purposeTypeControlGroup" class="control-group">
                <label class="control-label" for="purposeType">Purpose type:</label>
                <div class="controls">
                    <select class="myinput" id="purposeType" name="purposeType">
                        <option value="0" disabled="true" selected="true">choose purpose type</option>
                            <c:forEach var="purposeType" items="${purposeTypeList}">
                                <option value="<c:out value="${purposeType.toString()}" />"><c:out value="${purposeType.toString()}" /></option>
                            </c:forEach>
                    </select>
                    <span id="purposeTypeHelpInline" class="help-inline"></span>
                </div>
            </div>
                    
            <div class="form-actions">
                <input type="submit" class="btn btn-primary" name="saveButton" value="Create new bus">
                <button class="btn" id="cancelButton" name="cancelButton" data-button-to-click="cancelButtonOutOfForm">Cancel</button>
            </div>
        
        </fieldset>
    </form>
    
    <button class="btn" id="cancelButtonOutOfForm" data-link="bus-list" style="display: none; visibility: hidden; height: 0px; width: 0px;">Cancel</button>
</div>